package May22ch19ex2;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class MyAnnotations {
	public static void main(String[] args) throws IllegalArgumentException,
			IllegalAccessException {
		List<Person> persons = new ArrayList<Person>();

		persons.add(new Person("Mark", "Marecki", "AOL"));
		persons.add(new Person("Tomek", "Tomaszewski", "Google"));
		processPersons(persons);
		for (Person person : persons) {
			System.out.println(person);
		}
	}

	private static void processPersons(List<Person> persons)
			throws IllegalArgumentException, IllegalAccessException {
		Field[] declaredFields = Person.class.getDeclaredFields();
		for (Field field : declaredFields) {
			field.setAccessible(true);
			if (field.getType() == String.class) {

				for (Person person : persons) {
					String string = (String) field.get(person);
					field.set(person, ":" + string + ":");

				}
			}
		}
	}
}
